package org.flexlancer.controller
{
	import flash.display.Bitmap;
	
	import mx.containers.Canvas;
	import mx.controls.Label;
	import mx.core.UIComponent;
	
	public class Picture extends Canvas
	{
		/*
		variables
		*/
		private var _name:String;
		private var _quality:String;
		private var _path:String;
		private var _id:String;
		private var _selected:Boolean;
		private var _lbl:Label;
		private var _bitmap:Bitmap;
		private var _uic:UIComponent;
		/*
		constructor
		*/
		public function Picture(parmBitmap:Bitmap,
								parmName:String = "", 
								parmQuality:String = "" , 
								parmPath:String = "", 
								parmID:String = "")
		{
			super();
			this._lbl = new Label();
			
			this.Name = parmName;
			this._quality = parmQuality;
			this._path = parmPath;
			this._id = parmID;
			this._uic = new UIComponent();
			this._uic.addChild(parmBitmap);
			this.addChild(this._uic);
			
			this._lbl.setStyle("color",0xff0000);
			this.addChild(this._lbl);
			this._bitmap = parmBitmap;
		}
		
		public function set Name(val:String) : void{
			this._name = val;
			this._lbl.text = val;
		}		
		
		public function get Name():String {
			return this._name;
		}
		
		public function set Quality(val:String) : void{
			this._quality = val;
		}
		
		public function get Quality():String{
			return this._quality;
		}
		
		public function set Path ( val:String):void {
			this._path = val;
		}
		
		public function get Path ():String {
			return this._path;
		}
		
		public function set ID(val:String):void{
			this._id = val;
		}
		
		public function get ID():String{
			return this._id;
		}
		public function get BitMap():Bitmap{
			return new Bitmap(this._bitmap.bitmapData);
		}
		public function get BitMap2():Bitmap{
			var bm:Bitmap = new Bitmap(this._bitmap.bitmapData);
			bm.scaleX = 0.5;
			bm.scaleY = 0.5;
			return bm;
		}
		public function get UIC():UIComponent{
			return this._uic;
		}
		public function set Selected(val:Boolean):void{
			try{
				this._selected = val;
				if ( val ) {
					this.setStyle("borderStyle","solid");
					this.setStyle("borderColor",0xff0000);
					this.setStyle("borderThickness",2);
				}else{
					this.setStyle("borderStyle","none");
				}
			}catch(err:Error){
				throw err;
			}
		}
		
		public function get Selected():Boolean{
			return this._selected;
		}
	}
}